<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of softMin</title>
  <meta name="keywords" content="softMin">
  <meta name="description" content="Calculates the softMin of a vector.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html classify -->
<h1>softMin
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Calculates the softMin of a vector.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function M = softMin( D, sigma ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Calculates the softMin of a vector.

 Let D be a vector.  Then the softMin of D is defined as:
   s = exp(-D/sigma^2) / sum( exp(-D/sigma^2) )
 The softMin is a way of taking a dissimilarity (distance) vector D and
 converting it to a similarity vector s, such that sum(s)==1. If D is an
 NxK array, is is treated as N K-dimensional vectors, and the return is
 likewise an NxK array.  This is useful if D is a distance matrix,
 generated by the likes of pdist2.

 Note that as sigma-&gt;0, softMin's behavior tends toward that of the
 standard min function.  That is the softMin of a vector D has all zeros
 with a single 1 in the location of the smallest value of D. For example,
 &quot;softMin([.2 .4 .1 .3],eps)&quot; returns &quot;[0 0 1 0]&quot;.  As sigma-&gt;inf, then
 softMin(D,sigma) tends toward &quot;ones(1,n)/n&quot;, where n==length(D).

 If D contains the squared euclidean distance between a point y and k
 points xi, then there is a probabilistic interpretation for softMin.  If
 we think of the k points representing equal variant gaussians each with
 mean xi and std sigma, then the softMin returns the relative probability
 of y being generated by each gaussian.

 USAGE
  M = softMin( D, sigma )

 INPUTS
  D       - NxK dissimilarity matrix
  sigma   - controls 'softness' of softMin

 OUTPUTS
  M       - the softMin (indexes into D)

 EXAMPLE - 1
  C = [0 0; 1 0; 0 1; 1 1]; x=[.7,.3; .1 .2];
  D = pdist2( x, C ), M = softMin( D, .25 )

 EXAMPLE - 2
  fplot( 'softMin( [0.5 0.2 .4], x )', [0 5] );
  xlabel('sigma'); ylabel('assignments')

 See also <a href="pdist2.html" class="code" title="function D = pdist2( X, Y, metric )">PDIST2</a>, SOFTMAX

 Piotr's Computer Vision Matlab Toolbox      Version 2.0
 Copyright 2014 Piotr Dollar.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>





<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
